CC=g++

DEBUG_PATH = debug/
CLI_PATH = libcli/
XML_PATH = xml/
COM_PATH = common/
#EMULE_PATH = emule/
GRADING_PATH = grading/
PCRE_PATH = /usr/local/include
NGX_PATH = nginx-1.6.0

INCLUDE_PATH = include/
INCLUDE_OPT = -I$(INCLUDE_PATH) -I$(COM_PATH) -I$(CLI_PATH) -I$(XML_PATH) -I$(GRADING_PATH) -I$(PCRE_PATH) \
              -I$(NGX_PATH)/src/core/ -I$(NGX_PATH)/objs/ -I$(NGX_PATH)/src/os/unix/ \


CPPFLAGS =  -g -c -Wall -Wpointer-arith
#CPPFLAGS =  -g -c -O2 -Wall
OBJECTS = \
dns_decode.o spider_filter_rules.o pps.o utils.o sockfd.o idmgr.o libcli.o ppsadapter.o ipscopetbl.o dmacard.o pps_filt.o send_http_msg.o ppscommand.o worker.o ngx_alloc.o ngx_palloc.o

VPATH = $(CLI_PATH):$(XML_PATH):$(COM_PATH):$(INCLUDE_PATH)
ppsdlog_64_test: $(OBJECTS)
	$(CC) -g -o ppsdlog_64_test $(OBJECTS) libtinyxml.a libnetmap.a liblicense.a -lcrypt -lpthread  -L/usr/local/lib -lpcre

utils.o: utils.c
	$(CC) $(CPPFLAGS) $(COM_PATH)utils.c

sockfd.o: sockfd.c
	$(CC) $(CPPFLAGS) $(COM_PATH)sockfd.c

idmgr.o: idmgr.c idmgr.h
	$(CC) $(CPPFLAGS) $(COM_PATH)idmgr.c

sha1.o: sha1.cpp sha1.h
	$(CC) $(CPPFLAGS) $(COM_PATH)sha1.cpp

md5.o: md5.cpp md5.h
	$(CC) $(CPPFLAGS) $(COM_PATH)md5.cpp

libcli.o: libcli.c libcli.h
	$(CC) $(CPPFLAGS)  $(CLI_PATH)libcli.c

ppscommand.o: ppscommand.c ppscommand.h libcli.h ppsadapter.h utils.h 
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) ppscommand.c

ppsadapter.o: ppsadapter.c ppsadapter.h utils.h tinyxml.h 
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) ppsadapter.c

ipscopetbl.o: ipscopetbl.c ipscopetbl.h idmgr.h 
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) ipscopetbl.c

dmacard.o: dmacard.c dmacard.h
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) dmacard.c

dns_decode.o: dns_decode.c dns_decode.h
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) dns_decode.c

pps_filt.o: pps_filt.c utils.h  ppsadapter.h
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) pps_filt.c

send_http_msg.o: send_http_msg.c send_http_msg.h
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) send_http_msg.c

pps.o: pps.c pps.h ppsadapter.h dmacard.h utils.h libcli.h ppscommand.h tinyxml.h
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) pps.c

spider_filter_rules.o: spider_filter_rules.c spider_filter_rules.h
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) spider_filter_rules.c

worker.o: worker.c worker.h
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) worker.c

ngx_alloc.o: $(NGX_PATH)/src/os/unix/ngx_alloc.c
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) $(NGX_PATH)/src/os/unix/ngx_alloc.c

ngx_palloc.o: $(NGX_PATH)/src/core/ngx_palloc.c
	$(CC) $(CPPFLAGS) $(INCLUDE_OPT) $(NGX_PATH)/src/core/ngx_palloc.c

pkt_list.o: pkt_list.c pkt_list.h
	$(CC) -c pkt_list.c -o pkt_list.o

test: worker.o test.c 
	$(CC) -g -o test ngx_alloc.o ngx_palloc.o worker.o test.c -lpcap -lpthread

.PHONY:clean
clean:
	-rm $(OBJECTS)
	-rm ppsdlog_64
	-rm ppsdlog_64_test

